/*
 * StatusCode.h
 *
 *  Created on: Jan 16, 2010
 *      Author:
 */

#ifndef STATUSCODE_H_
#define STATUSCODE_H_

#include <string>
#include<iostream>
#include "Debug.h"
#include <string.h>
using namespace std;

typedef enum {

		HMC_Success = 0,
		HMC_Unknown_Equipment,//Can't get specfic equipment from equipmentlist
		HMC_Unknown_Attribute,//Can't get specfic attribute from equipment's Attributelist
		HMC_Unknown_Attribute_Type,//Can't specfic attribute type from attribute.
		HMC_Unknown_Attribute_CurrentValue,//Can't specfic currentVal from attribute.
		HMC_Unknown_Attribute_Parameter,//Unknow specfic attribute's parameter for attribute.
		HMC_InputValue_Outof_Range,
		HMC_Uknow_Equipment_Operation,
		HMC_Equipment_Operat_Failed,
		HMC_Equipment_Operat_Update_Failed,
		HMC_Unknown_Message,
		HMC_Unknown_Port, //can not get port name from portmanager
		HMC_Invail_Parameter,/* parameter of function error */
		HMC_Field_Over_Flow, /* when control message,parameter number overflow,for example,Message::getField()  */
		HMC_Message_ERROR, /* Message format error */
		HMC_PortSend_Error,
		HMC_PortGet_Error,
		HMC_PortSet_Error,
		HMC_Unsupport_PHP_Type, /* can not support current php message type */
		HMC_Unsupport_App_Type,
		HMC_PHP_Format_Error,  /* php message format not fit to require */
		HMC_Exist_Equipment, /* add new equipment or rename cause this error */
		HMC_Port_Occupied, /* when port occupied but want to use it */
		HMC_Open_DataBase_Fail, /* Can't open database successfully */
		HMC_Add_Equipment_Error,
		HMC_Open_File_Fail,/*can not open port file*/
		HMC_Unsupport_Device_Operation,//now not support operation
		HMC_Out_of_range, //for value out of range
		HMC_TimeOut,
		HMC_Invail_Instance,
		HMC_LoadDriver_Fail
}Hmc_Status_Key;

typedef struct {
	Hmc_Status_Key key;
	const char *msg;
}Status_Msg;

class StatusCode
{
public:
	StatusCode(int state = HMC_Success);
	~StatusCode();
	void setStatus(int state);
	int getStatus()const;

	int status; // it is better define with private,but it was used too much,so...

	char* PrintStatus(const string &identifier = "");
	int IfError();
private:
	char *status_msg;

	void setMsg(char * msg);
	char *getMsg()const;
};

#endif /* STATUSCODE_H_ */
